package cn.webrx;

import java.util.*;

public class List1 {
    public static void main(String[] args) {
        //接口
        //Collection c ;

        //子接口
        //List list1;



        //Set set1;

        //Collection->List=》ArrayList

        //List<Object>
        List list = new ArrayList();


        list.add("ok");
        list.add(100);
        list.add(0,"java");
        list.add(0,"java");
        list.add(0,"java");
        list.add(0,"java");
        list.add(0,"java");
        list.add(2,"mysql");

        //修改
        list.set(0,1000);

        //检查
        System.out.println(list.contains("mysql"));

        //返回-1 代表没有
        System.out.println(list.indexOf("php"));
        //list.indexOf()
        //list.lastIndexOf()

        //删除
        //list.remove("mysql");
        //list.remove(Integer.valueOf(1000));

        //只删除第一次出现的那个元素
        //list.remove("java");

        //循环删除所有java对象
        //while(list.contains("java")){
        //    list.remove("java");
        //}


        List re = new ArrayList();
        re.add("java");
        re.add("mysql");
        re.add("ok");
        //删除一群
        list.removeAll(re);

        //清空
        //list.clear();

        System.out.println(list.isEmpty());


        System.out.println(list.size());
        //System.out.println(list.get(0));
        //System.out.println(list.get(1));
        //System.out.println(list.get(3));


        for(Object i : list){
            System.out.println(i);
        }

        for(int i=0;i<list.size();i++){
            System.out.printf("list[%d] = %s%n",i,list.get(i));
        }
    }
}
